package com.cmfi.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cmfi.domain.ProductionRts;
import com.cmfi.service.inter.ProductionRtsService;
import com.cmfi.utils.Code;
import com.cmfi.utils.Result;

import lombok.extern.slf4j.Slf4j;

//return都是result

@Slf4j
@RestController
@RequestMapping("/api/productionrts")
public class ProductionRtsController {
    @Autowired
    private ProductionRtsService productionRtsService;
    static Logger log = LoggerFactory.getLogger(ProductionRtsController.class);
    
    /**
     * {@code GET  /productionrts} : get all the productionrtses.
     *
     * @param findByPage the pagination information.
     * @param request a {@link ServerHttpRequest} request.
     * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of readMes in body.
     */
    @GetMapping("/productionrts")
    @PreAuthorize("hasAuthority('realTimeStatus')")
    public Result getAllproductionRtses() {
    	log.debug("REST request to get a page of productionRtses");
    	List<ProductionRts> productionRtsList = null;
    	long total = 0;
    	try {
			productionRtsList = productionRtsService.findAllPositionStatus();
			total = productionRtsList.size();
    	} catch (Exception e) {
			log.error("[ProductionRtsController][getAllproductionRtses] e:{}", e);
			return new Result(Code.GET_ERR, e.getMessage());
		}
    		return new Result(Code.GET_OK, productionRtsList, total);
   }
    
}

